<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="../js/layui/css/layui.css"/>
    <script src="../js/layui/layui.js"></script>
    <script src="../js/jquery/jquery-1.9.1.js"></script>
</head>
<body>
<div class="layui-form">
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">职位：</label>
            <div class="layui-input-inline">
                <input class="layui-input" id="zhiweitype2" autocomplete="off">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">发布时间：</label>
            <div class="layui-input-inline">
                <input class="layui-input" id="date1" autocomplete="off">
            </div>
        </div>
        <div class="layui-inline">
            <div class="layui-input-inline">
                <input class="layui-input" id="date2" autocomplete="off">
            </div>
        </div>
        <div class="layui-inline">
            <button class="layui-btn" data-type="reload" onclick="searchs()">搜索</button>
        </div>
    </div>
</div>
    <!--批量删除-->
    <div class="layui-btn-container">
        <button class="layui-btn layui-btn-sm" lay-event="getCheckData" onclick="delManyProduct()">批量删除</button>
    </div>
    <!--列表-->
    <table id="date" lay-filter="test" ></table>
    <!--岗位详情-->
    <!--操作按钮-->
    <div id="toolbar" style="display: none;">
        <a class="layui-btn layui-btn-xs" lay-event="edit">查看详情</a>
        <a class="layui-btn layui-btn-xs" id="zhiding" lay-event="show">置顶(50$/2h)</a>
    </div>

                                                          <!-- --------------修改--------------------------->
    <div id="add-main" style="display: none;">
        <div class="layui-form-item">
            <label class="layui-form-label">招聘人数</label>
            <div class="layui-input-block">
                <input type="text" id="howmany"  placeholder="" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">职业类别</label>
            <div class="layui-input-inline">
                <input type="text" id="worktype"  placeholder="请输入类别" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">职位描述</label>
            <div class="layui-input-block">
                <textarea placeholder="请输入内容" class="layui-textarea" id="miaoshu"></textarea>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">公司待遇</label>
            <div class="layui-input-block">
                <input type="text" id="daiyuid"  placeholder="" autocomplete="off" class="layui-input">
            </div>
        </div>
    </div>
</body>
<script>
    var table = null;
        layui.use(['table','layer','form','element','laydate'], function() {
            table = layui.table;
        var element = layui.element;
        var layer = layui.layer;
        var form = layui.form;
        var laydate = layui.laydate;
            //日期
            laydate.render({
                elem: '#date1'
            });
            laydate.render({
                elem: '#date2'
            });
        $(function () {
            table.render({
                elem: '#date',
                id:'zhaoPinTableId',
                fit: true,
                cellMinWidth: true, //全局定义常规单元格的最小宽度，layui 2.2.1 新增
                url: '../zsl/queryZhaoPin', //数据接口
                type: "POST",
                loading: false,
                page: true,//开启分页
                cellMinWidth: 80, //全局定义常规单元格的最小宽度，layui 2.2.1 新增
                limits: [1,5,30,40,50,60,70,80,90],//page 代表当前页码、limit 代表每页数据量
                cols: [
                    [ //表头
                        {title: 'ID', checkbox: true},
                        {field: 'title', title: '标题', align: 'center'},
                        {field: 'xinzi', title: '薪资', align: 'center', sort: true,templet:function (d) {
                                return d.xinzi+"k";
                            }},
                        {field: 'daiyuid', title: '待遇', align: 'center'},
                        {field: 'fabudate', title: '发布时间', align: 'center', sort: true},
                        {field: 'yaoqiu', title: '学历要求', align: 'center'},
                        {field: 'howmany', title: '招聘人数', align: 'center', sort: true},
                        {field: 'zhiweitype', title: '职位类别', align: 'center'},
                        {field: 'touch', title: '联系人', align: 'center'},
                        {field: 'zhidingTime', title: '置顶时间', align: 'center'},
                        {field: 'status', title: '发布状态', align: 'center',templet:function (d) {
                                if (d.status  == 1){
                                    return "审核中";
                                }
                                if (d.status  == 2){
                                    return "审核通过";
                                }
                                if (d.status  == 3){
                                    return "时间到期";
                                }
                                if (d.status  == 4){
                                    return "暂停找人";
                                }
                                if (d.status  == 5){
                                    return "审核失败";
                                }
                            }},
                        {fixed: 'right',title: '操作', width: 250, align: 'center', toolbar: '#toolbar'}
                    ]
                ]
            });
        })
            // 监听你的表格
            table.on('tool(test)', function(obj) {
                var data = obj.data;
                var id = data.id
                var name = data.name
                if(obj.event==="edit"){
                    layer.open({
                        type: 1,
                        title:"招聘岗位详情",
                        closeBtn: false,
                        shift: 2,
                        area: ['800px', '500px'],
                        shadeClose: true,
                        content: $("#add-main"),
                        success: function(layero, index){
                            $('#id').val(data.id);
                            var temp;
                            if (data.worktype == 1){
                                temp ="全职";
                            }
                            if (data.worktype == 2){
                                temp ="兼职";
                            }
                            if (data.worktype == 3){
                                temp ="实习";
                            }
                            $('#worktype').val(temp);
                            $('#worknian').text(data.worknian);
                            $('#howmany').text(data.howmany);
                            $('#yaoqiu').text(data.yaoqiu);
                            $('#tel').val(data.tel);
                            $('#email').text(data.email);
                            $('#howmany').val(data.howmany);
                            $('#miaoshu').val(data.miaoshu);
                            $('#email').val(data.email);
                            $('#daiyuid').val(data.daiyuid);
                        },
                        yes:function(){
                        }
                    });
                }
                if (obj.event==="show"){
                    if (data.zhidingTime != null){
                        layer.alert("您已购买")
                        return;
                    }
                    layer.alert(id)
                    var temp = 1;
                    var price = 50;
                    $.ajax({
                        url:'../zsl/adddingdan',
                        type:'post',
                        data:{price:price,id:id,temp:temp},
                        success:function (data) {
                            location.href='../goAlipay?price='+price;
                        }
                    })
                }
            })
    })
        function searchs(){
            table.reload("zhaoPinTableId",{
                where: { //设定异步数据接口的额外参数，任意设
                    zhiweitype: $("#zhiweitype2").val(),//这里获取input的值
                    startTime:$("#date1").val(),
                    endTime:$("#date2").val(),
                }
                ,page: {
                    curr: 1 //重新从第 1 页开始
                }
            });
        }

        function delManyProduct(){
                var checkStatus = table.checkStatus("zhaoPinTableId");
                var data = checkStatus.data;
                var ids = "";
                for (var i = 0; i <data.length ; i++) {
                    ids += ids == "" ? data[i].id : ","+data[i].id;
                }

                $.post("../zsl/del",{id:ids},function(data){
                    if(data == "1"){
                        layer.alert("删除成功");
                        layer.close();
                        table.reload("zhaoPinTableId",{})
                    }else{
                        layer.alert("删除失败");
                    }
                })
        }


    //查看详情




</script>
</html>